import { CodeToText } from 'element-china-area-data'

export function getCodeToText(codeStr, codeArray) {
  if (codeStr === null && codeArray === null) {
    return null
  } else if (codeArray === null) {
    codeArray = codeStr.split(',')
  }

  let area = ''
  switch (codeArray.length) {
    case 1:
      area += CodeToText[codeArray[0]]
      break
    case 2:
      area += CodeToText[codeArray[0]] + '/' + CodeToText[codeArray[1]]
      break
    case 3:
      area +=
        CodeToText[codeArray[0]] +
        '/' +
        CodeToText[codeArray[1]] +
        '/' +
        CodeToText[codeArray[2]]
      break
    default:
      break
  }
  return area
}
